
package com.netease.xone.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.widget.FrameLayout;

import com.netease.pkgRelated.XoneConsts;
import com.netease.xone.R;
import com.netease.xone.fragment.FragmentBase;
import com.netease.xone.fragment.FragmentMenuFeedBack;
import com.netease.xone.fragment.FragmentMenuReport;

public class ActivityDetailMenuContainer extends ActivityX1Base {
    // 举报
    public static final int TYPE_REPORT = 0;
    // 反馈
    public static final int TYPE_FEEDBAK = 1;
    
    public static final String TAG = ActivityDetailMenuContainer.class.getSimpleName();
    

    public static void launch(Context context, int type, String infoId, String title) {
        Intent i = new Intent(context, ActivityDetailMenuContainer.class);
        i.putExtra(XoneConsts.EXTRA_OPERATE, type);
        i.putExtra(XoneConsts.EXTRA_PATH, infoId);
        i.putExtra(XoneConsts.EXTRA_DURATION, title);
        context.startActivity(i);
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        Intent intent = getIntent();
        int type = 0;
        String infoId = null;
        String title = null;
        if (intent != null) {
            type = intent.getIntExtra(XoneConsts.EXTRA_OPERATE, 0);
            infoId = intent.getStringExtra(XoneConsts.EXTRA_PATH);
            title = intent.getStringExtra(XoneConsts.EXTRA_DURATION);
        }
        
        FrameLayout linear = new FrameLayout(this);
        linear.setId(R.id.activity_detail_menu_container_id);
        setContentView(linear);
        
        if (findViewById(R.id.activity_detail_menu_container_id) != null && savedInstanceState == null) {
            FragmentManager fm = getSupportFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            FragmentBase frag = null;
            switch(type){
                case TYPE_REPORT:
                    frag = FragmentMenuReport.newInstance(infoId);
                    break; 
                case TYPE_FEEDBAK:
                    frag = FragmentMenuFeedBack.newInstance(infoId, title);
                    break; 
            }
           
            ft.add(R.id.activity_detail_menu_container_id, frag, TAG);
            ft.commit();
        }
    }
}
